package controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import pojo.User;
import service.UserService;

@Controller
public class UserController {
	
	public UserController() {
		System.out.println("controller");
	}
	
	@Resource(name="userService") 
	private UserService userService;
	
	@RequestMapping(value="/register")
	public String register(String uname,String pwd,int age){
		User user = new User("", uname, pwd, age);
		userService.login(user);
		return "login";
	}
	
	@RequestMapping(value="/login")
	public String login(String uname,String pwd){
		User user = userService.findByName(uname,pwd);
		System.out.println(user);
		if(user!=null){
			return "suc";
		}else{
			return "login";
		}
		
	}
	
}
